package com.example.demo.filters.outbound;

import com.example.demo.filters.inbound.MetricsInboundFilter;
import com.netflix.zuul.context.SessionContext;
import com.netflix.zuul.filters.http.HttpInboundSyncFilter;
import com.netflix.zuul.filters.http.HttpOutboundSyncFilter;
import com.netflix.zuul.message.http.HttpRequestMessage;
import com.netflix.zuul.message.http.HttpResponseMessage;

/**
 * @author sleepforests
 * Created on 2019-06-27
 */
public class MetricsOutboundFilter extends HttpOutboundSyncFilter {


    @Override
    public int filterOrder() {
        return -2;
    }

    @Override
    public HttpResponseMessage apply(HttpResponseMessage input) {
        SessionContext ctx = input.getContext();
        Long begin = (Long) ctx.get(MetricsInboundFilter.METRICS_FILTER_KEY);

        //  拿到时间 然后打点


        return input;
    }


    @Override
    public boolean shouldFilter(HttpResponseMessage msg) {
        return false;
    }
}
